package com.zc.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

//import com.zc.dao.IDataDao;
import com.zc.dao.IVibDao;
import com.zc.domain.FourPointsItem;
import com.zc.domain.Item;
import com.zc.service.VibService;

@Service(value="vibService")
public class VibServiceImpl implements VibService {
	@Autowired
	private IVibDao vibDao;
	@Override
	public FourPointsItem getSubVibration() {
		return vibDao.getVibration("fzd");
	}
	@Override
	public FourPointsItem getMainVibration() {
		return vibDao.getVibration("mzd");
	}
	@Override
	public List<FourPointsItem> getTodayVibration(boolean flag) {
		String tableName=flag?"mzd_h":"fzd_h";
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
        String date=df.format(new Date());// new Date()为获取当前系统时间
        List<FourPointsItem> vibData=vibDao.getTodayVib(tableName, date);
        for(FourPointsItem i:vibData) {
			i.setTimeStamp(i.getTimeStamp().substring(11, 13));
		}
        return vibData;
	}
}
